package com.cyy.friend.dao;


import com.cyy.friend.pojo.Friend;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

public interface FriendDao extends JpaRepository<Friend,String> {

    /**
     * 根据用户id和被关注用户id查询记录数
     */
    @Query("select count(f) from Friend f where f.userid = ?1 and f.friendid = ?2")
    public int selectCount(String userid,String friendid);

    /**
     * 更新为互相喜欢
     */
    @Modifying
    @Query("update Friend  f set f.islike = ?3 where f.friendid = ?1 and f.userid = ?2")
    public void updateLike(String friend,String userid,String isLike);


    /**
     * 删除喜欢
     */
    @Modifying
    @Query("delete from Friend f where f.userid = ?1 and f.friendid = ?2")
    public void deleteFriend(String userid,String friendid);
}
